package brad.zimmerman.dungeon.game;

import android.graphics.Bitmap;
import android.graphics.Matrix;

class ClassGraphicObject {
    /**
     * Contains the coordinates of the graphic.
     */
    
    public class Coordinates {
        public int _x;
        public int _y;

        public int getX() {
            return _x;
        }

        public void setX(int value) {
        	_x = value;
        }

        public int getY() {
            return _y;
        }

        public void setY(int value) {
            _y = value;
        }
        
        public String toString() {
            return "Coordinates: (" + _x + "/" + _y + ")";
        }
    }

    private Bitmap _bitmap;
    private Coordinates _coordinates;

    public ClassGraphicObject(Bitmap bitmap) {
        _bitmap = bitmap;
        _coordinates = new Coordinates();
    }

    public Bitmap getGraphic() {
        return _bitmap;
    }

    public Coordinates getCoordinates() {
        return _coordinates;
    }
    
    public Matrix returnMatrix(int width, int height, int scale, boolean expand){
    	
    	/*
    	 scaledBitmap = Bitmap.createBitmap(newWidth, newHeight, Config.ARGB_8888);

		float ratioX = newWidth / (float) bitmap.getWidth();
		float ratioY = newHeight / (float) bitmap.getHeight();
		float middleX = newWidth / 2.0f;
		float middleY = newHeight / 2.0f;

		Matrix scaleMatrix = new Matrix();
		scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);

		Canvas canvas = new Canvas(scaledBitmap);
		canvas.setMatrix(scaleMatrix);
		canvas.drawBitmap(bitmap, middleX - bitmap.getWidth() / 2, middleY - bitmap.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));
    	 */
    	float scaleWidth;
    	float scaleHeight;
    	
    	if(!expand){
    		scaleWidth = ((float) scale) / width;
    		scaleHeight = ((float) scale) / height;
    	}else{
    		scaleWidth = scale * width;
    		scaleHeight = scale * height;
    	}
    	Matrix matrix = new Matrix();
    	matrix.postScale(scaleWidth, scaleHeight);
    	
    	return matrix;
    }
    
}
